home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gui4cli / tools / rtn / viewfile < prev   
Text File  |  1999-04-29  |  4KB  |  165 lines

  1. G4C  
  2.  
  3. ; ViewFile FileName FileType Mode
  4.  
  5. ; FileName = the File Name
  6. ; FileType = the File Type, as returned from the GetFileType routine
  7. ; Mode     = (optional) CLI or RUN (RUN is default)
  8.  
  9. ; ======================================================================
  10.  
  11. xONLOAD filename filetype mode
  12. ; load the 8SVX player
  13. ; ifexists assign guis:
  14. ;   ifexists file guis:ext/gcsound/gcsound
  15. ;      run 'guis:ext/gcsound/gcsound'
  16. ;   endif
  17. ; endif
  18. guiopen viewfile $filename $filetype $mode
  19.  
  20. xONQUIT
  21. ; ifexists port gcsound    ; quit 8svx player
  22. ;    call gcsound quit
  23. ; endif
  24.  
  25. xONRELOAD filename filetype mode
  26. guiopen viewfile $filename $filetype $mode
  27.  
  28. xONOPEN filename filetype mode
  29.  
  30. if $filename = ''
  31. or $filetype = ''
  32.    return
  33. endif
  34.  
  35. docase $filetype
  36.  
  37. ; ----- do special cases first.
  38.  
  39. case   = TEXT                        ; a text file (probably)
  40.        GuiLoad guis:tools/read.gc $viewfile/filename
  41.        return
  42.        break
  43.  
  44. case   = INFO                     ; icons
  45.        if $filename[-1][1] = \"    ; remove the .info extention
  46.           cutvar filename cut char -6 ''
  47.           appvar filename \"
  48.        else
  49.           cutvar filename cut char -5 ''
  50.        endif
  51.        guiload guis:tools/icon.gc $viewfile/filename
  52.        return
  53.        break
  54.  
  55. case   = G4C                  ; Yes.. you guessed it.
  56.        GuiLoad $filename
  57.        return
  58.        break
  59.  
  60. case   = LHA                  ; LhA - all these are CLI'ied
  61.        cli '$*DEF.LHA x $filename ram:'
  62.        return
  63.        break
  64.   
  65. case   = LZX                  ; LZX
  66.        cli 'LZX x $filename ram:'
  67.        return
  68.        break
  69.  
  70. case   = ZIP                  ; unzip - it blocks the shell - why ???
  71.        cli 'run >nil: <nil: $*DEF.UNZIP $filename -d ram:'
  72.        return
  73.        break
  74.  
  75. case   = EXE                  ; A program ? - Use cli.gc to run it.
  76.        GuiLoad guis:tools/cli.gc $viewfile/filename RUN
  77.        return
  78.        break
  79.  
  80. case   = UNKNOWN
  81.        ; gui to deal with it..
  82.        guiopen ViewFile2
  83.        return
  84.        break
  85.  
  86. case   = 8SVX                     ; try internal player *NO*
  87.     ; ifexists port gcsound
  88.       ; call gcsound sound $filename 1    ; play it once
  89.     ; else
  90.        filetype = SMPL    ; otherwise use def player
  91.     ; endif
  92.         ; return
  93.  
  94. endcase
  95.  
  96. ; If we got this far, then it's one of the simple types such as
  97. ; GIF or ILBM etc - We just contruct & issue the command to run it.
  98.  
  99. com = '\$*DEF.$filetype'       ; construct command name
  100. if $mode == CLI
  101.    CLI '$com $filename'  
  102. else
  103.    RUN '$com $filename'  
  104. endif
  105.  
  106.  
  107. ; routine ends here.
  108.  
  109. xOnQuit
  110. guiquit ViewFile2
  111.  
  112.  
  113. ; ######################################################################
  114.  
  115.      NEWFILE Viewfile2     ; last chance gui
  116.  
  117. ; ######################################################################
  118.  
  119. WinBig 0 0 80 90 ""
  120. WinType 00001000
  121. winonmouse 40 10
  122. varpath viewfile    ; merge variables with the above file
  123.  
  124. xOnRMB 
  125. guiclose ViewFile2
  126.  
  127. xOnInactive
  128. guiclose ViewFile2
  129.  
  130. xOnFail
  131. ezreq "Error during operation" OK ""
  132.  
  133. ;---------------> the Buttons
  134.  
  135. xbutton 0 0 0 15 MView
  136. guiclose ViewFile2
  137. run 'multiview $filename screen'
  138.  
  139. xbutton 0 15 0 15 List
  140. GuiLoad  guis:tools/read.gc $viewfile/filename
  141.  
  142. xbutton 0 30 0 15 Play16
  143. guiclose ViewFile2
  144. run '$*DEF.SMPL $filename'
  145.  
  146. xbutton 0 45 0 15 Run
  147. guiclose ViewFile2
  148. run '$filename'
  149.  
  150. xbutton 0 60 0 15 With..
  151. guiclose ViewFile2
  152. prog = ''
  153. ReqFile  -1 -1 300 220 'Run file with..' LOAD prog hd1:Players
  154. if $prog > ''
  155.    run '$prog $filename'
  156. endif
  157.  
  158. xbutton 0 75 0 15 'CliGui'
  159. guiclose ViewFile2
  160. setvar cl_Main '$filename '
  161. GuiLoad guis:tools/cli.gc $viewfile/filename CLI
  162. setgad cli.gc 1 ON
  163.  
  164.  
  165.